from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from chaojiying import Chaojiying_Client
from selenium.webdriver.chrome.options import Options
from selenium import webdriver

option = webdriver.ChromeOptions()
option.add_experimental_option("detach",True)

web = Chrome(options=option)

web.get("http://www.chaojiying.com/user/login/")

#处理验证码
img = web.find_element(by=By.XPATH, value="/html/body/div[3]/div/div[3]/div[1]/form/div/img").screenshot_as_png
chaojiying = Chaojiying_Client('aTao18830251032', 'aTao121333', '932061')
dic = chaojiying.PostPic(img, 1902)
verify_code = dic['pic_str']

#输入用户名和密码
web.find_element(by=By.XPATH, value='/html/body/div[3]/div/div[3]/div[1]/form/p[1]/input').send_keys("aTao18830251032")
web.find_element(by=By.XPATH, value='/html/body/div[3]/div/div[3]/div[1]/form/p[2]/input').send_keys('aTao121333')
web.find_element(by=By.XPATH, value='/html/body/div[3]/div/div[3]/div[1]/form/p[3]/input').send_keys(verify_code)

#点击登录
web.find_element(by=By.XPATH, value='/html/body/div[3]/div/div[3]/div[1]/form/p[4]/input').click()



